package com.jstyle.beatecg.base;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Toast;




/**
 * Created by Administrator on 2017/3/22.
 */

public  class BaseActivity extends AppCompatActivity {

    protected  static Toast toast;
    protected ProgressDialog progressDialog;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            getWindow().requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS);
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
        }
    }



    protected   void showStatusBar(){};

    protected void showToast(String text){
        if(toast==null){
            toast= Toast.makeText(getApplicationContext(),text, Toast.LENGTH_SHORT);
        }else{
            toast.setText(text);
        }
        toast.show();
    }
    protected void startActivity(Class activity){
        Intent intent =new Intent(this,activity);
        startActivity(intent);
    }

//    @Override
//    protected void attachBaseContext(Context newBase) {
//        super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
//    }

    protected void showProgressDialog(String message){
        if(isDestroyed())return;
        if(progressDialog==null){
            progressDialog=new ProgressDialog(this);

            progressDialog.setMessage(message);
        }
        progressDialog.show();
    }

    protected  void disMissProgressDialog(){
        if(isDestroyed())return;
        if(progressDialog!=null&&progressDialog.isShowing()){
            progressDialog.dismiss();
        }
    }


}
